﻿<Button Text="点击弹出表单编辑弹窗" OnClickWithoutRender="@ShowDialog" />
<Logger @ref="Trace" class="mt-3" />

@code {
    private BindItem Model { get; set; } = new BindItem()
    {
        Name = "Name 1234",
        Address = "Address 1234"
    };

    [Inject]
    [NotNull]
    private DialogService? DialogService { get; set; }

    [NotNull]
    private Logger? Trace { get; set; }

    private async Task ShowDialog()
    {
        var option = new EditDialogOption<BindItem>()
        {
            Title = "编辑对话框",
            Model = Model,
            OnCloseAsync = () =>
            {
                Trace.Log("关闭按钮被点击");
                return Task.CompletedTask;
            },
            OnSaveAsync = context =>
            {
                Trace.Log("保存按钮被点击");
                return Task.FromResult(true);
            }
        };

        await DialogService.ShowEditDialog(option);
    }
}
